<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body {
      font-family: "Helvetica", "Arial", sans-serif;
      font-size: 10pt;
    }
    abbr {
      text-decoration: none;
      border: 0;
      font-style: normal;
    }
  </style>
</head>
<body>
  <h1>what is the Document Object Model?</h1>
  <p>
    The <abbr title="world wide web consortium">W3C</abbr> defines the <abbr title="Document">DOM</abbr> as:
  </p>
  <blockquote cite="http://www.w3.org/DOM/">
    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Harum tempore quibusdam rerum, incidunt ratione eius quidem, nesciunt error, ea pariatur illo similique eveniet. Perspiciatis amet aliquam, ipsam quam in esse.</p>
  </blockquote>
  <p>
    It is an <abbr title="Application Programming Interface">API</abbr> that can be used to navigate
    <abbr title="HyperText Markup Language">HTML</abbr> and <abbr title="extensible Markup Language">XML</abbr> documents.
  </p>


  <!-- <dl>
    <dt>W3C</dt>
    <dd>world wide web consortium</dd>
    <dt>DOM</dt>
    <dd>Document Object Model</dd>
    <dt>API</dt>
    <dd>Application Programming Interface</dd>
    <dt>XML</dt>
    <dd>extensible Markup Language</dd>
  </dl> -->

  <script>    
    function displayAbbreviations() {
      if (!document.getElementsByTagName || !document.createElement || !document.createTextNode) {
        return false
      }
      const abbrs = document.getElementsByTagName('abbr')
      console.log(abbrs)
      if (abbrs.length < 1) {
        return false
      }
      const defs = {}
      for (let i = 0; i < abbrs.length; i++) {
        const abr = abbrs[i]
        if (abr.childNodes.length < 1) continue;

        const definition = abr.getAttribute('title')
        const key = abr.lastChild.nodeValue
        defs[key] = definition
      }

      const dl = document.createElement('dl')
      for (let [key, value] of Object.entries(defs)) {
        const dt = document.createElement('dt')
        const dd = document.createElement('dd')
        const dtTxt = document.createTextNode(key)
        const ddTxt = document.createTextNode(value)
        dt.appendChild(dtTxt)
        dd.appendChild(ddTxt)
        dl.appendChild(dt)
        dl.appendChild(dd)
      }
      document.body.appendChild(dl)
    }
    window.onload = displayAbbreviations
  </script>
</body>
</html>